#!/usr/bin/env python
'''
plots T_C(L) vs \ln(L) ^(-2)
'''
import matplotlib.pyplot
import math
import numpy

matplotlib.rc('xtick', labelsize = 12)
matplotlib.rc('ytick', labelsize = 12)
matplotlib.rcParams.update({'font.size': 15})

# tL2 = [8,    10,   12,   14,   16,   20,   36,   48]
# tT2 = [1.29, 1.23, 1.2, 1.18, 1.16, 1.13, 1.07, 1.05]


tL2 = [12,   14,   16,   20,   36,   48]
tT2 = [1.2, 1.18, 1.16, 1.13, 1.07, 1.05]

# tL1 = [12,   14,   16,   20,   36,   48]
# tT1 = [1.2, 1.18, 1.16, 1.13, 1.07, 1.05]
# tL2 = [16,   20,   36,  48]
# tT2 = [0.66, 0.66, 0.66, 0.66]

# tL = [12,   14,   16,   20,   36,   48]
# tT = [1.21, 1.18, 1.16, 1.125, 1.07, 1.05]

tL = [ math.pow(math.log(tl),-2) for tl in tL2 ]
# tL = [ math.pow(math.log(tl),-2) for tl in tL1 ]

A = numpy.vstack([tL, numpy.ones(len(tL2))]).T
# A = numpy.vstack([tL, numpy.ones(len(tL1))]).T

temp = numpy.linalg.lstsq(A, tT2)
# temp = numpy.linalg.lstsq(A, tT1)

m, c = temp[0]  
print 'm',m
print 'c',c

approxx = [0] + tL

# matplotlib.pyplot.ylabel(r'$T_{1C}(L)$')
matplotlib.pyplot.ylabel(r'$T_{2C}(L)$')

matplotlib.pyplot.xlabel(r'$\ln(L)^{-2}$')
# matplotlib.pyplot.text(0.1, 1, '$T_{1C}(L) = %.4f x$$+ %.4f$'%(m,c))
matplotlib.pyplot.text(0.1, 1, '$T_{2C}(L) = %.4f x$$+ %.4f$'%(m,c))

approxy = [m * tt + c for tt in approxx] 
# matplotlib.pyplot.plot(tL, tT1, 'o')
matplotlib.pyplot.plot(tL, tT2, 'o')

matplotlib.pyplot.plot(approxx, approxy,'--')


matplotlib.pyplot.show()